package com.aaa.system.controller;

import com.aaa.entity.Role;
import com.aaa.system.service.RoleService;
import com.aaa.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: aaa-education-parent
 * @description:
 * @author: 闫克起2
 * @create: 2024-03-08 10:55
 **/
@RestController
@RequestMapping("system/role")
public class RoleController {
    @Autowired
    private RoleService roleService;
    @GetMapping("getByUserId")
    public Result getByUserId(String userId){
         List<Role> roles=roleService.selectAll();
         List<String> roleIds= roleService.selectByUserId(userId);
         Map<String,Object> map=new HashMap<>();
         map.put("roles",roles);
         map.put("roleIds",roleIds);
         return new Result(2000,"查询成功",map);
    }

    @PostMapping("qrfp")
    public Result qrfp(String userId,String[] roleIds){
        roleService.qrfp(userId,roleIds);
        return new Result(2000,"分配成功",null);
    }
}
